import React from "react";
import { modalPropsType } from "@/constants/types";
import { Modal, Form, Input } from "antd";

const {Item} = Form;
const rules = [{required: true}];

const AddActivityCode = ({onCancel, onSubmit, title, visible, loading, currentRow}: modalPropsType) => {
  const [form] = Form.useForm()
  
  const handleSubmit = async () => {
    const res = await form.validateFields();
    onSubmit({
      ...res,
      activityId: currentRow?.id
    });
  }
  return (
    <Modal
      title={title}
      onCancel={onCancel}
      onOk={handleSubmit}
      maskClosable={false}
      confirmLoading={loading}
      open={visible}
    >
      <Form form={form} className="modal-form-padding">
        <Item label="活动名称">
          <Input disabled value={currentRow?.name} />
        </Item>
        <Item label="手机号" name="mobile" rules={rules}>
          <Input maxLength={11} />
        </Item>
      </Form>  
    </Modal>
  );
}
export default AddActivityCode;